export function formHasValue(fieldMap = {}, filterArray = true) {
  return Object.keys(fieldMap).reduce((rtv, key) => {
    const val = fieldMap[key]

    if (Object.prototype.toString.call(val) === '[object Object]') {
      rtv[key] = formHasValue(val, filterArray)
    } else if (filterArray) {
      if (val !== '' && val !== null && val !== undefined && val.length !== 0) {
        rtv[key] = val
      }
    } else {
      if (val !== '' && val !== null && val !== undefined) {
        rtv[key] = val
      }
    }

    return rtv
  }, {})
}
